// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.


suite("test_cast_to_float_from_datetimev2_3_part8") {

    // This test case is generated from the correspoinding be UT test case,
    // update this case if the correspoinding be UT test case is updated,
    // e.g.: ../run-be-ut.sh --run --filter=FunctionCastToDecimalTest.* --gen_regression_case
    sql "drop table if exists test_cast_to_float_from_datetimev2_3_part8_8_nullable;"
    sql "create table test_cast_to_float_from_datetimev2_3_part8_8_nullable(f1 int, f2 datetimev2(3)) properties('replication_num'='1');"
    sql """insert into test_cast_to_float_from_datetimev2_3_part8_8_nullable values (0, "2025-12-28 00:59:01.000"),(1, "2025-12-28 00:59:01.000"),(2, "2025-12-28 00:59:01.999"),(3, "2025-12-28 00:59:59.000"),(4, "2025-12-28 00:59:59.000"),(5, "2025-12-28 00:59:59.999"),(6, "2025-12-28 01:00:00.000"),(7, "2025-12-28 01:00:00.000"),(8, "2025-12-28 01:00:00.999"),(9, "2025-12-28 01:00:01.000"),(10, "2025-12-28 01:00:01.000"),(11, "2025-12-28 01:00:01.999"),(12, "2025-12-28 01:00:59.000"),(13, "2025-12-28 01:00:59.000"),(14, "2025-12-28 01:00:59.999"),(15, "2025-12-28 01:01:00.000"),(16, "2025-12-28 01:01:00.000"),(17, "2025-12-28 01:01:00.999"),(18, "2025-12-28 01:01:01.000"),(19, "2025-12-28 01:01:01.000"),
      (20, "2025-12-28 01:01:01.999"),(21, "2025-12-28 01:01:59.000"),(22, "2025-12-28 01:01:59.000"),(23, "2025-12-28 01:01:59.999"),(24, "2025-12-28 01:59:00.000"),(25, "2025-12-28 01:59:00.000"),(26, "2025-12-28 01:59:00.999"),(27, "2025-12-28 01:59:01.000"),(28, "2025-12-28 01:59:01.000"),(29, "2025-12-28 01:59:01.999"),(30, "2025-12-28 01:59:59.000"),(31, "2025-12-28 01:59:59.000"),(32, "2025-12-28 01:59:59.999"),(33, "2025-12-28 23:00:00.000"),(34, "2025-12-28 23:00:00.000"),(35, "2025-12-28 23:00:00.999"),(36, "2025-12-28 23:00:01.000"),(37, "2025-12-28 23:00:01.000"),(38, "2025-12-28 23:00:01.999"),(39, "2025-12-28 23:00:59.000"),
      (40, "2025-12-28 23:00:59.000"),(41, "2025-12-28 23:00:59.999"),(42, "2025-12-28 23:01:00.000"),(43, "2025-12-28 23:01:00.000"),(44, "2025-12-28 23:01:00.999"),(45, "2025-12-28 23:01:01.000"),(46, "2025-12-28 23:01:01.000"),(47, "2025-12-28 23:01:01.999"),(48, "2025-12-28 23:01:59.000"),(49, "2025-12-28 23:01:59.000"),(50, "2025-12-28 23:01:59.999"),(51, "2025-12-28 23:59:00.000"),(52, "2025-12-28 23:59:00.000"),(53, "2025-12-28 23:59:00.999"),(54, "2025-12-28 23:59:01.000"),(55, "2025-12-28 23:59:01.000"),(56, "2025-12-28 23:59:01.999"),(57, "2025-12-28 23:59:59.000"),(58, "2025-12-28 23:59:59.000"),(59, "2025-12-28 23:59:59.999"),
      (60, "9999-01-01 00:00:00.000"),(61, "9999-01-01 00:00:00.000"),(62, "9999-01-01 00:00:00.999"),(63, "9999-01-01 00:00:01.000"),(64, "9999-01-01 00:00:01.000"),(65, "9999-01-01 00:00:01.999"),(66, "9999-01-01 00:00:59.000"),(67, "9999-01-01 00:00:59.000"),(68, "9999-01-01 00:00:59.999"),(69, "9999-01-01 00:01:00.000"),(70, "9999-01-01 00:01:00.000"),(71, "9999-01-01 00:01:00.999"),(72, "9999-01-01 00:01:01.000"),(73, "9999-01-01 00:01:01.000"),(74, "9999-01-01 00:01:01.999"),(75, "9999-01-01 00:01:59.000"),(76, "9999-01-01 00:01:59.000"),(77, "9999-01-01 00:01:59.999"),(78, "9999-01-01 00:59:00.000"),(79, "9999-01-01 00:59:00.000"),
      (80, "9999-01-01 00:59:00.999"),(81, "9999-01-01 00:59:01.000"),(82, "9999-01-01 00:59:01.000"),(83, "9999-01-01 00:59:01.999"),(84, "9999-01-01 00:59:59.000"),(85, "9999-01-01 00:59:59.000"),(86, "9999-01-01 00:59:59.999"),(87, "9999-01-01 01:00:00.000"),(88, "9999-01-01 01:00:00.000"),(89, "9999-01-01 01:00:00.999"),(90, "9999-01-01 01:00:01.000"),(91, "9999-01-01 01:00:01.000"),(92, "9999-01-01 01:00:01.999"),(93, "9999-01-01 01:00:59.000"),(94, "9999-01-01 01:00:59.000"),(95, "9999-01-01 01:00:59.999"),(96, "9999-01-01 01:01:00.000"),(97, "9999-01-01 01:01:00.000"),(98, "9999-01-01 01:01:00.999"),(99, "9999-01-01 01:01:01.000"),
      (100, "9999-01-01 01:01:01.000"),(101, "9999-01-01 01:01:01.999"),(102, "9999-01-01 01:01:59.000"),(103, "9999-01-01 01:01:59.000"),(104, "9999-01-01 01:01:59.999"),(105, "9999-01-01 01:59:00.000"),(106, "9999-01-01 01:59:00.000"),(107, "9999-01-01 01:59:00.999"),(108, "9999-01-01 01:59:01.000"),(109, "9999-01-01 01:59:01.000"),(110, "9999-01-01 01:59:01.999"),(111, "9999-01-01 01:59:59.000"),(112, "9999-01-01 01:59:59.000"),(113, "9999-01-01 01:59:59.999"),(114, "9999-01-01 23:00:00.000"),(115, "9999-01-01 23:00:00.000"),(116, "9999-01-01 23:00:00.999"),(117, "9999-01-01 23:00:01.000"),(118, "9999-01-01 23:00:01.000"),(119, "9999-01-01 23:00:01.999"),
      (120, "9999-01-01 23:00:59.000"),(121, "9999-01-01 23:00:59.000"),(122, "9999-01-01 23:00:59.999"),(123, "9999-01-01 23:01:00.000"),(124, "9999-01-01 23:01:00.000"),(125, "9999-01-01 23:01:00.999"),(126, "9999-01-01 23:01:01.000"),(127, "9999-01-01 23:01:01.000"),(128, "9999-01-01 23:01:01.999"),(129, "9999-01-01 23:01:59.000"),(130, "9999-01-01 23:01:59.000"),(131, "9999-01-01 23:01:59.999"),(132, "9999-01-01 23:59:00.000"),(133, "9999-01-01 23:59:00.000"),(134, "9999-01-01 23:59:00.999"),(135, "9999-01-01 23:59:01.000"),(136, "9999-01-01 23:59:01.000"),(137, "9999-01-01 23:59:01.999"),(138, "9999-01-01 23:59:59.000"),(139, "9999-01-01 23:59:59.000"),
      (140, "9999-01-01 23:59:59.999"),(141, "9999-01-28 00:00:00.000"),(142, "9999-01-28 00:00:00.000"),(143, "9999-01-28 00:00:00.999"),(144, "9999-01-28 00:00:01.000"),(145, "9999-01-28 00:00:01.000"),(146, "9999-01-28 00:00:01.999"),(147, "9999-01-28 00:00:59.000"),(148, "9999-01-28 00:00:59.000"),(149, "9999-01-28 00:00:59.999"),(150, "9999-01-28 00:01:00.000"),(151, "9999-01-28 00:01:00.000"),(152, "9999-01-28 00:01:00.999"),(153, "9999-01-28 00:01:01.000"),(154, "9999-01-28 00:01:01.000"),(155, "9999-01-28 00:01:01.999"),(156, "9999-01-28 00:01:59.000"),(157, "9999-01-28 00:01:59.000"),(158, "9999-01-28 00:01:59.999"),(159, "9999-01-28 00:59:00.000"),
      (160, "9999-01-28 00:59:00.000"),(161, "9999-01-28 00:59:00.999"),(162, "9999-01-28 00:59:01.000"),(163, "9999-01-28 00:59:01.000"),(164, "9999-01-28 00:59:01.999"),(165, "9999-01-28 00:59:59.000"),(166, "9999-01-28 00:59:59.000"),(167, "9999-01-28 00:59:59.999"),(168, "9999-01-28 01:00:00.000"),(169, "9999-01-28 01:00:00.000"),(170, "9999-01-28 01:00:00.999"),(171, "9999-01-28 01:00:01.000"),(172, "9999-01-28 01:00:01.000"),(173, "9999-01-28 01:00:01.999"),(174, "9999-01-28 01:00:59.000"),(175, "9999-01-28 01:00:59.000"),(176, "9999-01-28 01:00:59.999"),(177, "9999-01-28 01:01:00.000"),(178, "9999-01-28 01:01:00.000"),(179, "9999-01-28 01:01:00.999"),
      (180, "9999-01-28 01:01:01.000"),(181, "9999-01-28 01:01:01.000"),(182, "9999-01-28 01:01:01.999"),(183, "9999-01-28 01:01:59.000"),(184, "9999-01-28 01:01:59.000"),(185, "9999-01-28 01:01:59.999"),(186, "9999-01-28 01:59:00.000"),(187, "9999-01-28 01:59:00.000"),(188, "9999-01-28 01:59:00.999"),(189, "9999-01-28 01:59:01.000"),(190, "9999-01-28 01:59:01.000"),(191, "9999-01-28 01:59:01.999"),(192, "9999-01-28 01:59:59.000"),(193, "9999-01-28 01:59:59.000"),(194, "9999-01-28 01:59:59.999")
      ,(195, null);
    """

    sql "set enable_strict_cast=true;"

    test {
        sql """select f1, cast(f2 as float) from test_cast_to_float_from_datetimev2_3_part8_8_nullable order by 1;"""
        exception ""
    }
    sql "set enable_strict_cast=false;"
    qt_sql_8_non_strict 'select f1, cast(f2 as float) from test_cast_to_float_from_datetimev2_3_part8_8_nullable order by 1;'

    sql "drop table if exists test_cast_to_float_from_datetimev2_3_part8_8_not_nullable;"
    sql "create table test_cast_to_float_from_datetimev2_3_part8_8_not_nullable(f1 int, f2 datetimev2(3)) properties('replication_num'='1');"
    sql """insert into test_cast_to_float_from_datetimev2_3_part8_8_not_nullable values (0, "2025-12-28 00:59:01.000"),(1, "2025-12-28 00:59:01.000"),(2, "2025-12-28 00:59:01.999"),(3, "2025-12-28 00:59:59.000"),(4, "2025-12-28 00:59:59.000"),(5, "2025-12-28 00:59:59.999"),(6, "2025-12-28 01:00:00.000"),(7, "2025-12-28 01:00:00.000"),(8, "2025-12-28 01:00:00.999"),(9, "2025-12-28 01:00:01.000"),(10, "2025-12-28 01:00:01.000"),(11, "2025-12-28 01:00:01.999"),(12, "2025-12-28 01:00:59.000"),(13, "2025-12-28 01:00:59.000"),(14, "2025-12-28 01:00:59.999"),(15, "2025-12-28 01:01:00.000"),(16, "2025-12-28 01:01:00.000"),(17, "2025-12-28 01:01:00.999"),(18, "2025-12-28 01:01:01.000"),(19, "2025-12-28 01:01:01.000"),
      (20, "2025-12-28 01:01:01.999"),(21, "2025-12-28 01:01:59.000"),(22, "2025-12-28 01:01:59.000"),(23, "2025-12-28 01:01:59.999"),(24, "2025-12-28 01:59:00.000"),(25, "2025-12-28 01:59:00.000"),(26, "2025-12-28 01:59:00.999"),(27, "2025-12-28 01:59:01.000"),(28, "2025-12-28 01:59:01.000"),(29, "2025-12-28 01:59:01.999"),(30, "2025-12-28 01:59:59.000"),(31, "2025-12-28 01:59:59.000"),(32, "2025-12-28 01:59:59.999"),(33, "2025-12-28 23:00:00.000"),(34, "2025-12-28 23:00:00.000"),(35, "2025-12-28 23:00:00.999"),(36, "2025-12-28 23:00:01.000"),(37, "2025-12-28 23:00:01.000"),(38, "2025-12-28 23:00:01.999"),(39, "2025-12-28 23:00:59.000"),
      (40, "2025-12-28 23:00:59.000"),(41, "2025-12-28 23:00:59.999"),(42, "2025-12-28 23:01:00.000"),(43, "2025-12-28 23:01:00.000"),(44, "2025-12-28 23:01:00.999"),(45, "2025-12-28 23:01:01.000"),(46, "2025-12-28 23:01:01.000"),(47, "2025-12-28 23:01:01.999"),(48, "2025-12-28 23:01:59.000"),(49, "2025-12-28 23:01:59.000"),(50, "2025-12-28 23:01:59.999"),(51, "2025-12-28 23:59:00.000"),(52, "2025-12-28 23:59:00.000"),(53, "2025-12-28 23:59:00.999"),(54, "2025-12-28 23:59:01.000"),(55, "2025-12-28 23:59:01.000"),(56, "2025-12-28 23:59:01.999"),(57, "2025-12-28 23:59:59.000"),(58, "2025-12-28 23:59:59.000"),(59, "2025-12-28 23:59:59.999"),
      (60, "9999-01-01 00:00:00.000"),(61, "9999-01-01 00:00:00.000"),(62, "9999-01-01 00:00:00.999"),(63, "9999-01-01 00:00:01.000"),(64, "9999-01-01 00:00:01.000"),(65, "9999-01-01 00:00:01.999"),(66, "9999-01-01 00:00:59.000"),(67, "9999-01-01 00:00:59.000"),(68, "9999-01-01 00:00:59.999"),(69, "9999-01-01 00:01:00.000"),(70, "9999-01-01 00:01:00.000"),(71, "9999-01-01 00:01:00.999"),(72, "9999-01-01 00:01:01.000"),(73, "9999-01-01 00:01:01.000"),(74, "9999-01-01 00:01:01.999"),(75, "9999-01-01 00:01:59.000"),(76, "9999-01-01 00:01:59.000"),(77, "9999-01-01 00:01:59.999"),(78, "9999-01-01 00:59:00.000"),(79, "9999-01-01 00:59:00.000"),
      (80, "9999-01-01 00:59:00.999"),(81, "9999-01-01 00:59:01.000"),(82, "9999-01-01 00:59:01.000"),(83, "9999-01-01 00:59:01.999"),(84, "9999-01-01 00:59:59.000"),(85, "9999-01-01 00:59:59.000"),(86, "9999-01-01 00:59:59.999"),(87, "9999-01-01 01:00:00.000"),(88, "9999-01-01 01:00:00.000"),(89, "9999-01-01 01:00:00.999"),(90, "9999-01-01 01:00:01.000"),(91, "9999-01-01 01:00:01.000"),(92, "9999-01-01 01:00:01.999"),(93, "9999-01-01 01:00:59.000"),(94, "9999-01-01 01:00:59.000"),(95, "9999-01-01 01:00:59.999"),(96, "9999-01-01 01:01:00.000"),(97, "9999-01-01 01:01:00.000"),(98, "9999-01-01 01:01:00.999"),(99, "9999-01-01 01:01:01.000"),
      (100, "9999-01-01 01:01:01.000"),(101, "9999-01-01 01:01:01.999"),(102, "9999-01-01 01:01:59.000"),(103, "9999-01-01 01:01:59.000"),(104, "9999-01-01 01:01:59.999"),(105, "9999-01-01 01:59:00.000"),(106, "9999-01-01 01:59:00.000"),(107, "9999-01-01 01:59:00.999"),(108, "9999-01-01 01:59:01.000"),(109, "9999-01-01 01:59:01.000"),(110, "9999-01-01 01:59:01.999"),(111, "9999-01-01 01:59:59.000"),(112, "9999-01-01 01:59:59.000"),(113, "9999-01-01 01:59:59.999"),(114, "9999-01-01 23:00:00.000"),(115, "9999-01-01 23:00:00.000"),(116, "9999-01-01 23:00:00.999"),(117, "9999-01-01 23:00:01.000"),(118, "9999-01-01 23:00:01.000"),(119, "9999-01-01 23:00:01.999"),
      (120, "9999-01-01 23:00:59.000"),(121, "9999-01-01 23:00:59.000"),(122, "9999-01-01 23:00:59.999"),(123, "9999-01-01 23:01:00.000"),(124, "9999-01-01 23:01:00.000"),(125, "9999-01-01 23:01:00.999"),(126, "9999-01-01 23:01:01.000"),(127, "9999-01-01 23:01:01.000"),(128, "9999-01-01 23:01:01.999"),(129, "9999-01-01 23:01:59.000"),(130, "9999-01-01 23:01:59.000"),(131, "9999-01-01 23:01:59.999"),(132, "9999-01-01 23:59:00.000"),(133, "9999-01-01 23:59:00.000"),(134, "9999-01-01 23:59:00.999"),(135, "9999-01-01 23:59:01.000"),(136, "9999-01-01 23:59:01.000"),(137, "9999-01-01 23:59:01.999"),(138, "9999-01-01 23:59:59.000"),(139, "9999-01-01 23:59:59.000"),
      (140, "9999-01-01 23:59:59.999"),(141, "9999-01-28 00:00:00.000"),(142, "9999-01-28 00:00:00.000"),(143, "9999-01-28 00:00:00.999"),(144, "9999-01-28 00:00:01.000"),(145, "9999-01-28 00:00:01.000"),(146, "9999-01-28 00:00:01.999"),(147, "9999-01-28 00:00:59.000"),(148, "9999-01-28 00:00:59.000"),(149, "9999-01-28 00:00:59.999"),(150, "9999-01-28 00:01:00.000"),(151, "9999-01-28 00:01:00.000"),(152, "9999-01-28 00:01:00.999"),(153, "9999-01-28 00:01:01.000"),(154, "9999-01-28 00:01:01.000"),(155, "9999-01-28 00:01:01.999"),(156, "9999-01-28 00:01:59.000"),(157, "9999-01-28 00:01:59.000"),(158, "9999-01-28 00:01:59.999"),(159, "9999-01-28 00:59:00.000"),
      (160, "9999-01-28 00:59:00.000"),(161, "9999-01-28 00:59:00.999"),(162, "9999-01-28 00:59:01.000"),(163, "9999-01-28 00:59:01.000"),(164, "9999-01-28 00:59:01.999"),(165, "9999-01-28 00:59:59.000"),(166, "9999-01-28 00:59:59.000"),(167, "9999-01-28 00:59:59.999"),(168, "9999-01-28 01:00:00.000"),(169, "9999-01-28 01:00:00.000"),(170, "9999-01-28 01:00:00.999"),(171, "9999-01-28 01:00:01.000"),(172, "9999-01-28 01:00:01.000"),(173, "9999-01-28 01:00:01.999"),(174, "9999-01-28 01:00:59.000"),(175, "9999-01-28 01:00:59.000"),(176, "9999-01-28 01:00:59.999"),(177, "9999-01-28 01:01:00.000"),(178, "9999-01-28 01:01:00.000"),(179, "9999-01-28 01:01:00.999"),
      (180, "9999-01-28 01:01:01.000"),(181, "9999-01-28 01:01:01.000"),(182, "9999-01-28 01:01:01.999"),(183, "9999-01-28 01:01:59.000"),(184, "9999-01-28 01:01:59.000"),(185, "9999-01-28 01:01:59.999"),(186, "9999-01-28 01:59:00.000"),(187, "9999-01-28 01:59:00.000"),(188, "9999-01-28 01:59:00.999"),(189, "9999-01-28 01:59:01.000"),(190, "9999-01-28 01:59:01.000"),(191, "9999-01-28 01:59:01.999"),(192, "9999-01-28 01:59:59.000"),(193, "9999-01-28 01:59:59.000"),(194, "9999-01-28 01:59:59.999");
    """

    sql "set enable_strict_cast=true;"

    test {
        sql """select f1, cast(f2 as float) from test_cast_to_float_from_datetimev2_3_part8_8_not_nullable order by 1;"""
        exception ""
    }
    sql "set enable_strict_cast=false;"
    qt_sql_8_non_strict 'select f1, cast(f2 as float) from test_cast_to_float_from_datetimev2_3_part8_8_not_nullable order by 1;'

}